package aa;

import java.io.IOException;
import java.util.Scanner;

public class Test4 {
	int n = 3;
	int[] a = new int[n+1];
	int[] book = new int[n+1];
    int total=0;
	private void dfs(int step) {
		if (step == 4) {
			for (int i = 1; i <=3 ; i++) {
				System.out.print(a[i]);
			}
			System.out.println();
			return;
		}
		for (int i = 1; i <=3; i++) {
			if (book[i]==0) {
				a[step]=i;
				book[i]=1;
				dfs(step+1);
				book[i]=0;
			}
		}
		return;
	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		new Test4().dfs(sc.nextInt());
		sc.close();
		
	}

}
